package excercise;

import java.util.Scanner;

public class EX05_031 {
	
	public static void main(String[] args) {
	
		Scanner sc = new Scanner(System.in);
		MyCardVO mc = new MyCardVO();
		
		while (true) {
			System.out.print("조회하실 카드번호를 입력하시오");
			mc.setMyCard(sc.next());
			if( MyCardService.checkMyCard(mc.getMyCard()) == null ) {
				System.out.println("카드번호를 잘못입력하셨습니다. 다시 입력하세요");
			} else { mc.setCardImfo(MyCardService.checkMyCard(mc.getMyCard())); break; }
		}
		
		System.out.println(mc.toString());
	}

}

class MyCardVO {
	private String mycard;
	private String cardImfo;
	
	public MyCardVO() {
		mycard = null;
		cardImfo = null;
		}
	public MyCardVO(String mycard) { this.mycard = mycard; }
	
	public void setMyCard(String mycard) { this.mycard = mycard; }
	public void setCardImfo(String cardImfo) { this.cardImfo = cardImfo; }
	public String getMyCard() { return mycard; }
	public String getCardImfo() { return cardImfo; }
	
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("○ 입력하신 카드 정보 ○").append("\n○ 카드 번호 : ").append(getMyCard().substring(0, 4))
		.append(" - ").append(getMyCard().substring(4, 6)).append("\n○ 카드 종류 / 은행 : ").append(getCardImfo());
		return sb.toString();
	}
}

class MyCardService {
	
	static String checkMyCard(String myCard) {
		String result = null;
		switch(myCard.substring(0, 1)) {
		case "3" :
			result =  "JCB카드";
			switch(myCard.substring(5, 6)) {
			case "1" :
				result = result + " / " + "신한은행";
				return result;
			case "2" :
				result = result + " / " + "KB국민은행";
				return result;
			case "7" :
				result = result + " / " + "NH농협";
				return result;
			default :
				return "";
			}
		case "4" :
			result = "비자카드";
			switch(myCard.substring(5, 6)) {
			case "3" :
				result = result + " / " + "KB국민은행";
				return result;
			case "5" :
				result = result + " / " + "비씨카드";
				return result;
			case "6" :
				result = result + " / " + "신한은행";
				return result;
			default :
				return "";
			}
		case "5" :
			result = "마스타카드 / Maestro";
			switch(myCard.substring(5, 6)) {
			case "3" :
				result = result + " / " + "외환은행";
				return result;
			case "4" :
				result = result + " / " + "신한은행";
				return result;
			case "6" :
				result = result + " / " + "KB국민은행";
				return result;
			default :
				return "";
			}
		default :
			return "";
		} 
	} 
}
